package com.gan.project.service.impl.inner;



import com.alibaba.nacos.common.utils.StringUtils;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.gan.ganapicommon.model.entity.InterfaceInfo;
import com.gan.ganapicommon.service.InnerInterfaceInfoService;
import com.gan.project.common.ErrorCode;
import com.gan.project.exception.BusinessException;
import com.gan.project.mapper.InterfaceInfoMapper;
import org.apache.dubbo.config.annotation.DubboService;

import javax.annotation.Resource;

/**
 * @author gan
 * @date 2023/5/9 14:38
 */
@DubboService
public class InnerInterfaceInfoServiceImpl implements InnerInterfaceInfoService {

    @Resource
    private InterfaceInfoMapper interfaceInfoMapper;
    @Override
    public InterfaceInfo getInterfaceInfo(String path, String method) {
        if (StringUtils.isAnyBlank(path,method)){
            throw new BusinessException(ErrorCode.PARAMS_ERROR);
        }
        QueryWrapper<InterfaceInfo> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("url",path);
        queryWrapper.eq("method",method);
        return  interfaceInfoMapper.selectOne(queryWrapper);
    }
}
